﻿
using ContactSMS.Commons.Util;

namespace ContactSMS.Domain.Entity
{
    public class Contact
    {
        public long Id { get; set; }
        public long UserId { get; set; }
        public string Name { get; set; }
        public string Initial { get; set; }
        public string PinYin { get; set; }
        public string? Company { get; set; }
        public string? Position { get; set; }
        public string? Note { get; set; }
        public long CreatTime { get; set; }
        public long UpdateTime { get; set; }
        public virtual List<Phone>? Phones { get; set; }

        public Contact()
        { }

        public Contact(string Name, string? Company, string? Position, string? note, long UserId = 0)
        {
            this.UserId = UserId;
            this.Name = Name;
            var result = PinyinHelper.GetInitialsAndFullPinyin(Name);
            this.Initial = PinyinHelper.GetFirstCharToLower(result.Initials);
            this.PinYin = result.FullPinyin;
            this.Company = Company;
            this.Position = Position;
            this.Note = note;
            this.CreatTime = TimeUtil.GetTimestamp();
            this.UpdateTime = TimeUtil.GetTimestamp();
        }
    }
}
